import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import render from '@dfeidao/atom-mobile/render/render';
import whoami from '../atom/whoami_getparams';

export default async function a001(fd: IFeidaoAiMobile) {
	// init
	const p = await whoami(fd) as { params: { teacher_no: string; } };
	if (!p.params.teacher_no) {
		console.log('只有教师可以访问此页面！');
		return;
	}
	const teacher_no = p.params.teacher_no;
	const page_no = 1;
	const d = await nodejs<{
		d: Array<{
			key: {};
		}>,
		total_size: number
	}>('app-student-list/s001', {
		filter: {
			teacher_no// : 'JS0004'
		},
		page_no
	});
	render(fd, { ...d, page_no, new_len: d.d.length });
	set(fd, 'pre_d', d.d);
	set(fd, 'teacher_no', teacher_no);
}
